package com.baggio.locationex.location;

import com.amap.api.location.AMapLocation;
import com.amap.api.location.AMapLocationListener;
import com.baggio.locationex.MainActivityCallback;
import com.baggio.locationex.platform.BgLocationData;
import com.baidu.location.BDAbstractLocationListener;
import com.baidu.location.BDLocation;

public class BgLocationListener extends BDAbstractLocationListener implements AMapLocationListener {

    public MainActivityCallback mainActivityCallback = null;

    public BgLocationListener(MainActivityCallback callback) {
        mainActivityCallback = callback;
    }

    @Override
    public void onReceiveLocation(BDLocation bdLocation) {
        // 此处的BDLocation为定位结果信息类，通过它的各种get方法可获取定位相关的全部结果

        BgLocationData locationData = new BgLocationData();

        // 纬度
        locationData.latitude = bdLocation.getLatitude();
        // 经度
        locationData.longitude = bdLocation.getLongitude();
        // 精度
        locationData.radius = bdLocation.getRadius();
        // 速度
        locationData.speed = bdLocation.getSpeed();
        // 方向
        locationData.direction = bdLocation.getDirection();
        // 时间
        locationData.timeString = bdLocation.getTime();
        // 卫星数量
        locationData.satelliteNumber = bdLocation.getSatelliteNumber();

        // 坐标类型
        locationData.coorType = bdLocation.getCoorType();

        // 拿到了定位数据后，想办法回调给界面显示
        if (mainActivityCallback != null) {
            mainActivityCallback.UpdateLocationData(locationData);
        }
    }

    @Override
    public void onLocationChanged(AMapLocation aMapLocation) {
        BgLocationData locationData = new BgLocationData();
    }
}
